#pragma once

#include "../base_outputer.h"
#include "../../common/timercpp.h"
#include <atomic>
#include <mutex>
#include "protocol_N2.h"

class Outputer14 : public BaseOutputer
{
public:
    Outputer14();
    ~Outputer14();

    virtual void UpdateCompassTime(TIME_Field_t *message);
    virtual void UpdateRadarPoint(CCVBlockInfo *message);

    virtual void UpdateAisInfo(const ship_info* info);
    virtual void UpdateRadarInfo(const radar_info* info);

private:
    void RadarTrackerUpdate();
    void GyroUpdate();
    bool SendCompass(const compass_info& info);

    void SendGyro(const compass_info& info);
    void SendGps(const compass_info& info);

    void SendRadarTrackers();
    void SendRadarDots();

    void InitRadarTrackerData();
    void InitRadarPointData();
private:
    Timer m_gyro_sender;
    info_keys m_gyro_key;

    std::mutex m_tracks_mutex;
    protocol_N2::Info_RadarTrack m_track_data;
    std::atomic<unsigned int> m_radar_tracker_count;

    std::mutex m_dot_mutex;
    protocol_N2::Info_RadarDot m_dot_data;
    std::atomic<unsigned int> m_radar_dot_count;

    Timer m_radar_timer;
};